<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>集合</title>
</head>
<body>

</body>
<script>
    //Set集合
    let s = new Set();
    let s1 =new Set(['张三','李四','王五' ]);

    //size属性
    console.log(s1.size );

    //add方法
    s1.add('赵六');

    //delete方法
    s1.delete('张三');

    console.log(s1);

    //查询元素是否存在
    console.log(s1.has('张三'));

    s.clear();

    //forof遍历
    for (const sElement of s1) {
        console.log(sElement);
    }


    //map集合
    let m = new Map();
    m.set('hello','world');

    m.set('change',()=>{
        console.log('map的方法。')
    })

    const key= {
        addr : 'addr'
    }

    m.set(key,['北京','上海','深圳'])


    for (const sElement of m) {
        console.log(sElement);
    }

    console.log(m.get('hello'));

    m.clear();






</script>
</html>